﻿Public Class AnneeMoisConverter
    Public Shared Function AnneeMoisToString_Simple(Annee As Nullable(Of Integer), Mois As Nullable(Of Integer)) As String
        Dim result As String = "-"
        If Annee.HasValue And Mois.HasValue Then
            Dim MoisReal As String
            If Mois < 10 Then MoisReal = "0" & Mois Else MoisReal = CStr(Mois)
            result = CStr(Annee) & MoisReal
        End If
        Return result
    End Function
    Public Shared Function AnneeMoisToString_Compose(Annee As Nullable(Of Integer), Mois As Nullable(Of Integer)) As String
        Dim result As String = "-"
        If Annee.HasValue And Mois.HasValue Then
            Dim MoisReal As String
            If Mois < 10 Then MoisReal = "0" & Mois Else MoisReal = CStr(Mois)
            result = String.Format("{0}-{1}", CStr(Annee), MoisReal)
        End If
        Return result
    End Function


    Public Shared Function MoisToString(value As Integer)
        Dim MoisReal As Integer = CInt(value)
        If MoisReal = 0 Then
            Return ""
        ElseIf MoisReal < 10 Then
            Return "0" & CStr(MoisReal)
        Else
            Return CStr(MoisReal)
        End If
    End Function

    Public Shared Function StringToMois(value As String)
        Return CInt(value)
    End Function

End Class
